<?php

/**
 * Articles form base class.
 *
 * @method Articles getObject() Returns the current form's model object
 *
 * @package    explications_informatiques
 * @subpackage form
 * @author     Guimezanes Cyrille
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseArticlesForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'idarticles'    => new sfWidgetFormInputHidden(),
      'category'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Categories'), 'add_empty' => false)),
      'title'         => new sfWidgetFormInputText(),
      'description'   => new sfWidgetFormTextarea(),
      'online'        => new sfWidgetFormInputText(),
      'date_creation' => new sfWidgetFormDateTime(),
      'hits'          => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'idarticles'    => new sfValidatorChoice(array('choices' => array($this->getObject()->get('idarticles')), 'empty_value' => $this->getObject()->get('idarticles'), 'required' => false)),
      'category'      => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Categories'))),
      'title'         => new sfValidatorString(array('max_length' => 150, 'required' => false)),
      'description'   => new sfValidatorString(array('required' => false)),
      'online'        => new sfValidatorString(array('max_length' => 1, 'required' => false)),
      'date_creation' => new sfValidatorDateTime(),
      'hits'          => new sfValidatorInteger(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('articles[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Articles';
  }

}
